TOOLCHAIN = i586-elf-

CC = $(TOOLCHAIN)gcc
LD = $(TOOLCHAIN)ld
AS = $(TOOLCHAIN)as
OBJCOPY = $(TOOLCHAIN)objcopy
OBJDUMP = $(TOOLCHAIN)objdump

all: boot0 trampoline

boot0: boot0.S boot0.c
	$(CC) -nostdlib -c -o boot0s.o boot0.S
	$(CC) -O -nostdlib -ffreestanding -c -o boot0c.o boot0.c
	$(LD) -N -e start -Ttext 0x7c00 -o boot0.o boot0s.o boot0c.o
	$(OBJCOPY) -S -O binary boot0.o boot0
	./sign.pl boot0

trampoline: trampoline.S
	$(CC) -nostdlib -c -o trampoline.o trampoline.S
	$(LD) -N -e start -Ttext 0x7000 -o trampoline.out trampoline.o
	$(OBJCOPY) -S -O binary trampoline.out trampoline

clean:
	rm *.o boot0 trampoline trampoline.out

